/*
\ brief:  工厂模式实现文件
\ author: 清晨与猫鱼
*/
#include <iostream>     // 引入依赖库

/*
\ brief :   抽象接口类
\ author : 清晨与猫鱼
*/
class Shape {
public:
    virtual void draw() = 0;         // 抽象接口函数
};


/*
\ brief :  长方形继承抽象接口类 Shape
\ author : 清晨与猫鱼
*/
class Rectangle 
    : public Shape {
public:

    void draw() {
        std::cout << "Rectangle" << std::endl;
    }
};



/*
\ brief :  正方形继承抽象接口类 Shape
\ author : 清晨与猫鱼
*/
class Square 
    : public Shape {
public:
    void draw() {
        std::cout << "Square" << std::endl;
    }
};


/*
\ brief :  圆形继承抽象接口类 Shape
\ author : 清晨与猫鱼
*/
class Circle 
    : public Shape {
public:
    void draw() {
         std::cout << "Circle" << std::endl;
    }
};


/*
\ brief :  工厂类
\ author : 清晨与猫鱼
*/
class ShapeFactory {
public:

/*
\ brief:  根据标识 觉定new 那个类型的对象
\ param:
\ return:
\ author: 清晨与猫鱼
*/
    static Shape* getShape(const std::string& shapeType) {
        if (shapeType.empty()) {
            return nullptr;
        }else if (shapeType == "Rectangle") {
            return new Rectangle();
        }else if (shapeType == "Square") {
            return new Square();
        }else if (shapeType == "Circle") {
            return new Circle();
        }
        
        return nullptr;
    }
};


